package com.shengqin.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * <p>
 * 体测计划
 * </p>
 *
 * @author Rui.Zhou
 * @since 2023-12-05
 */
@TableName("t_plan")
@Schema(name = "Plan对象", description = "体测计划")
@Data
public class Plan implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @Schema(description = "计划编码")
    private String code;

    @Schema(description = "计划名称")
    private String name;

    @Schema(description = "起止时间")
    private LocalDate startDate;

    @Schema(description = "结束时间")
    private LocalDate endDate;

    @Schema(description = "所属学年")
    private String schoolYear;

    @Schema(description = "成绩选取规则 1.最新成绩;2.最好成绩")
    private String planRuleType;

    @Schema(description = "体测地点")
    private String testAddress;

    @Schema(description = "检录数据是否自动上传")
    private Boolean uploadFlag;

    @Schema(description = "计划状态 1.未开始 2.进行中 3.已结束")
    private Integer state;

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @Schema(description = "创建人")
    private Integer createUserId;

    @Schema(description = "父计划ID")
    private Integer parentId;

    @Schema(description = "是否是考试计划")
    private Boolean examFlag = false;

    private Integer templateId;
    private Integer calculateType = 1;

    private Boolean openReservation = false;

    @TableField(exist = false)
    private List<String> selectClassesList;

    private String cameraIp;

    private Integer studentNum;
    private Integer schoolNum;

    @TableField(exist = false)
    private List<String> studyCodes;
    @TableField(exist = false)
    private String templateName;

    @TableField(exist = false)
    private List<Plan> childPlans;
    @TableField(exist = false)
    private String stateDesc;
    @TableField(exist = false)
    private String resultQueryUrl;

    public String getResultQueryUrl() {
        return "http://front.sqcoe.com?planId=" + this.id;
    }

    public String getStateDesc() {
        String stateDesc = "";
        switch (state) {
            case 1:
                stateDesc = "未开始";
                break;
            case 2:
                stateDesc = "进行中";
                break;
            case 3:
                stateDesc = "已结束";
                break;
            case 4:
                stateDesc = "已关闭";
                break;
        }
        return stateDesc;
    }
}
